<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        span{
            display: inline-block;
            width: 70px;
            text-align: center;
            margin: 5px;
            border: 1px solid #ccc;
        }
    </style>
</head>

<body>
    <div id="app"></div>
    <script>
        const app = document.getElementById('app')
        for (let i = 1; i <= 9; i++) {
            let div = document.createElement("div")
            for (let j = 1; j <= i; j++) {
                let span = document.createElement("span")
                let color='#'+Math.random().toString(16).substring(2,8)
                console.log(color);
                
                span.innerText = j+'*'+i+'='+j*i
                span.style.backgroundColor=color
                div.appendChild(span)
            }
            app.appendChild(div)
        }
    </script>
</body>

</html>